package com.wcs.spring.mapper;

/** 
 * 
 * @author geloin 
 * @date 2012-5-5 上午10:26:34 
 */

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.wcs.spring.entity.User;

/**
 * @author geloin
 * @date 2012-5-5 上午10:26:34
 */
@Repository(value = "userMapper")
public interface UserMapper {

	@Select(value = "${sql}")
	List<User> queryUserList(@Param(value = "sql") String sql);

	@Select(value = "${sql}")
	User queryUserByParam(@Param(value = "sql") String sql);

	@Insert("insert into user (userName,password,sex,telNo,mobile,userType,address,onlineStartDate,"
			+ "onlineEndDate,offlineStartDate,offlineEndDate,schoolName,majorName,studentLevel,"
			+ "chineseName,englishName,schoolId,createTime,createUser,updateTime,updateUser,flag) "
			+ "values (#{u.userName},#{u.password},#{u.sex},#{u.telNo},#{u.mobile},"
			+ "#{u.userType},#{u.address},#{u.onlineStartDate},#{u.onlineEndDate},#{u.offlineStartDate},#{u.offlineEndDate},"
			+ "#{u.schoolName},#{u.majorName},#{u.studentLevel},#{u.chineseName},#{u.englishName},#{u.schoolId},"
			+ "#{u.createTime},#{u.createUser},#{u.updateTime},#{u.updateUser},0)")
	int addUser(@Param("u") User user);

	@Insert(value = "${sql}")
	int addUser2(@Param("u") User user, @Param(value = "sql") String sql);

	@Update(value = "${sql}")
	void updateUser(@Param(value = "sql") String sql);

	@Update("UPDATE user SET flag=1 WHERE id=#{u.id}")
	void delUser(@Param("u") User user);

	@Delete("DELETE FROM user WHERE id = #{u.id}")
	void deleteUser(@Param("u") User user);

	@Select({ "SELECT * FROM user WHERE id = #{id}" })
	User queryUserById(Integer id);

}
